﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Globalization;

namespace Boomerang.Common.Sms
{
    [Serializable()]
    public class SmsConnectionOptions
    {
        public string LicenseKey { get; set; }

        public string BoomerangUserName { get; set; }

        public string BoomerangPassword { get; set; }

        public string ServerUrl { get; set; }

        public string UserName { get; set; }

        public string Password { get; set; }

        public string Domain { get; set; }

        public bool UseHttps { get; set; }

        public bool UseDefaultCredentials { get; set; }

        private string Protocol
        {
            get
            {
                if (!this.UseHttps)
                {
                    return "http";
                }
                return "https";
            }
        }

        public string GetBoomerangServiceUrl()
        {
            return string.Format(CultureInfo.InvariantCulture, "{0}://{1}", this.Protocol, this.ServerUrl);
        }

        public ICredentials GetBoomerangCredentials()
        {
            if (!this.UseDefaultCredentials)
            {
                return new NetworkCredential(this.UserName, this.Password, this.Domain);
            }
            return CredentialCache.DefaultCredentials;
        }

    }
}
